package ar.edu.caece.compiler.grammar.factories;

import ar.edu.caece.compiler.grammar.AbstractTokenVisitorFactory;
import ar.edu.caece.compiler.grammar.TokenVisitor;

public class EXPR3Factory extends AbstractTokenVisitorFactory {

	private static EXPR3Factory INSTANCE;
	
	private EXPR31Factory expr31Factory;
	private VALORFactory valorFactory;
	private EXPR33Factory expr33Factory;
	private EXPR34Factory expr34Factory;
	private EXPR35Factory expr35Factory;

	
	
	public static EXPR3Factory getInstance() throws Exception {
		if(INSTANCE==null) INSTANCE = new EXPR3Factory();
		return INSTANCE;
	}
	
	private Initializer initializer = new Initializer() {
		
		@Override
		public void init() throws Exception {
			initializer = NoOperationInitializer.getInstance();
			expr31Factory = EXPR31Factory.getInstance();
			valorFactory = VALORFactory.getInstance();
			expr33Factory = EXPR33Factory.getInstance();
			expr34Factory = EXPR34Factory.getInstance();
			expr35Factory = EXPR35Factory.getInstance();
		}
	};
	
	
	private EXPR3Factory() throws Exception {

	}
	
	@Override
	public TokenVisitor makeChainedVisitor(
			final TokenVisitor siguiente) throws Exception {
		initializer.init();

		return expr31Factory.makeChainedVisitor(valorFactory.makeChainedVisitor(expr33Factory.makeChainedVisitor(expr34Factory.makeChainedVisitor(expr35Factory.makeChainedVisitor(siguiente)))));
	
	}
	@Override
	public TokenVisitor makeVisitor() throws Exception {
		initializer.init();

		return expr31Factory.makeChainedVisitor(valorFactory.makeChainedVisitor(expr33Factory.makeChainedVisitor(expr34Factory.makeChainedVisitor(expr35Factory.makeVisitor()))));
	}
	
	
}
